/**
 *
 * Licensed Materials - Property of IBM 
 * 
 * OCO Source Materials 
 * 
 * (C) Copyright IBM Corp. 2011, 2012 All Rights Reserved 
 * 
 * The source code for this program is not published or other- 
 * wise divested of its trade secrets, irrespective of what has 
 * been deposited with the U.S. Copyright Office. 
 *
 */

/**
 * CHANGE HiSTORY:
 * Author             Time                 Description
 *
 */

package com.ibm.ba.demo.controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.ibm.ba.demo.entity.AuthRequest;

/**
 * AuthenticationController is to handle request related to authenticate.
 * 
 * @author Luyi
 */
@Controller
@SessionAttributes("auth")
public class AuthenticationController extends AbstractController {

	// private static String SCORE_VIEW_NAME = "get_scores";
	private static String LOGIN_VIEW_NAME = "loginres";
	private static Logger logger = Logger
			.getLogger(AuthenticationController.class);

	/**
	 * Map request URI - '/login' to method - 'login()'. Login the ba demo
	 * portal.
	 */
	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String login(ModelMap model, @ModelAttribute AuthRequest request) {
		System.out.println(request.getCustId());
		model.addAttribute("auth", request);
		logger.info("login(ModelMap model) begin");
		logger.info("login(ModelMap model) end");
		// return SCORE_VIEW_NAME;
		return LOGIN_VIEW_NAME;
	}
}
